home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
cinidemo
/
ftestini.frm
< prev
next >
Wrap
Text File
|
1998-05-10
|
11KB
|
381 lines
VERSION 5.00
Begin VB.Form fTestIni
Caption = "cINIFile Class Demonstration Application"
ClientHeight = 5670
ClientLeft = 3645
ClientTop = 2310
ClientWidth = 7200
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "fTestIni.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5670
ScaleWidth = 7200
Begin VB.PictureBox pnlButtons
BorderStyle = 0 'None
Height = 2895
Left = 5340
ScaleHeight = 2895
ScaleWidth = 1875
TabIndex = 10
Top = 180
Width = 1875
Begin VB.CommandButton cmdCreate
Caption = "Re-&Create Test Ini"
Height = 430
Left = 0
TabIndex = 16
Top = 0
Width = 1800
End
Begin VB.CommandButton cmdEnumSection
Caption = "&Enumerate Section...."
Height = 430
Left = 0
TabIndex = 15
Top = 480
Width = 1800
End
Begin VB.CommandButton cmdGetValue
Caption = "&Get Value for Key..."
Height = 430
Left = 0
TabIndex = 14
Top = 960
Width = 1800
End
Begin VB.CommandButton cmdDeleteKey
Caption = "&Delete Key..."
Height = 430
Left = 0
TabIndex = 13
Top = 1920
Width = 1800
End
Begin VB.CommandButton cmdDeleteSection
Caption = "Delete &Section..."
Height = 430
Left = 0
TabIndex = 12
Top = 2400
Width = 1800
End
Begin VB.CommandButton cmdSetValue
Caption = "Set &Value for Key..."
Height = 430
Left = 0
TabIndex = 11
Top = 1440
Width = 1800
End
End
Begin VB.ListBox lstIni
Height = 5325
Left = 180
TabIndex = 9
Top = 180
Width = 5115
End
Begin VB.Frame fraInfo
Caption = "cIniFile Parameters:"
Height = 2535
Left = 5340
TabIndex = 0
Top = 3060
Width = 1815
Begin VB.TextBox txtInfo
Height = 315
Index = 3
Left = 120
TabIndex = 8
Top = 2100
Width = 1635
End
Begin VB.TextBox txtInfo
Height = 315
Index = 2
Left = 120
TabIndex = 7
Top = 1500
Width = 1635
End
Begin VB.TextBox txtInfo
Height = 315
Index = 1
Left = 120
TabIndex = 6
Top = 960
Width = 1635
End
Begin VB.TextBox txtInfo
Height = 315
Index = 0
Left = 120
TabIndex = 5
Top = 420
Width = 1635
End
Begin VB.Label lblInfo
Caption = "Value:"
Height = 195
Index = 3
Left = 120
TabIndex = 4
Top = 1860
Width = 1995
End
Begin VB.Label lblInfo
Caption = "Key:"
Height = 195
Index = 2
Left = 120
TabIndex = 3
Top = 1320
Width = 1995
End
Begin VB.Label lblInfo
Caption = "Section:"
Height = 195
Index = 1
Left = 120
TabIndex = 2
Top = 780
Width = 1995
End
Begin VB.Label lblInfo
Caption = "Path:"
Height = 195
Index = 0
Left = 60
TabIndex = 1
Top = 180
Width = 1695
End
End
End
Attribute VB_Name = "fTestIni"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_cIni As New cInifile
Private Sub ShowIniAndParameters()
Dim sGet As String
Dim sSections() As String
Dim iSectionCount As Long
Dim sKeys() As String
Dim iKeycount As Long
Dim iSection As Long
Dim iKey As Long
Dim lSect As Long
lstIni.Clear
With m_cIni
.EnumerateAllSections sSections(), iSectionCount
For iSection = 1 To iSectionCount
lstIni.AddItem "[" & sSections(iSection) & "]"
lSect = lstIni.NewIndex
lstIni.ItemData(lSect) = -1
.Section = sSections(iSection)
.EnumerateCurrentSection sKeys(), iKeycount
For iKey = 1 To iKeycount
.Key = sKeys(iKey)
lstIni.AddItem .Key & "=" & .Value
lstIni.ItemData(lstIni.NewIndex) = lSect
Next iKey
Next iSection
If (lstIni.ListCount > 0) Then
lstIni.ListIndex = lstIni.ListCount - 1
End If
txtInfo(0) = .Path
txtInfo(1) = .Section
txtInfo(2) = .Key
txtInfo(3) = .Value
End With
End Sub
Private Sub CreateTestIni()
Dim i As Long
Dim iNd As Long
' Create an Ini File to play with:
On Error Resume Next
Kill App.Path & "\TEST.INI"
On Error GoTo 0
With m_cIni
.Path = App.Path & "\TEST.INI"
.Section = "Window"
.Key = "Toolbar"
.Value = "1"
.Key = "Statusbar"
.Value = "1"
.Key = "Maximised"
.Value = (Me.WindowState = vbMaximized)
.Key = "Left"
.Value = Me.Left
.Key = "Top"
.Value = Me.Top
.Key = "Width"
.Value = Me.Width
.Key = "Height"
.Value = Me.Height
.Key = "Title"
.Value = App.Title
.Section = "Options"
.Key = "ShowTips"
.Value = "1"
.Key = "OpenInNewWindow"
.Value = "0"
.Section = "Controls"
For i = 0 To Me.Controls.Count - 1
.Key = "Control" & i
Err.Clear
On Error Resume Next
iNd = Me.Controls(i).Index
If (Err.Number = 0) Then
.Value = Me.Controls(i).Name & "," & CStr(iNd)
Else
.Value = Me.Controls(i).Name
End If
Next i
End With
ShowIniAndParameters
End Sub
Private Sub cmdCreate_Click()
CreateTestIni
End Sub
Private Sub cmdDeleteKey_Click()
With m_cIni
.Path = txtInfo(0)
.Section = txtInfo(1)
.Key = txtInfo(2)
.DeleteKey
If Not (.Success) Then
MsgBox "Delete Key Failed.", vbInformation
End If
End With
ShowIniAndParameters
End Sub
Private Sub cmdDeleteSection_Click()
With m_cIni
.Path = txtInfo(0)
.S